home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
001a
/
sendcom@.zip
/
SENDCOM.C
< prev
next >
Wrap
Text File
|
1991-10-10
|
3KB
|
119 lines
#include <stdlib.h>
#include <stdio.h>
#include <sys\stat.h>
#include <fcntl.h>
#include <ctype.h>
#include <dos.h>
#include <string.h>
#define CR "\n\r"
#define rs232 0x14
#define writech 1
#define mask 0x7f
#define DATA_READY 0
#define OVERRUN 0x1
#define PARITY 0x2
#define FRAMING 0x8
#define BRK 0x10
#define HOLDEMPTY 0x20
#define SHIFTEMPTY 0x40
#define FAILED 0x80
union REGS regs;
int COMPORT,mode,fileflag;
char commandline[255];
char filter[80];
extern int ANSI;
char *pcb_printf(char *);
/*::::::::::::::::::::::::[ DISPLAY SECURITY FILE ]::::::::::::::::::::*/
display_file(char *filename){
FILE *fp;
char buffer[85];
int bufflen=80;
if((fp=fopen(filename,"r"))==NULL){
strcpy(commandline,filename);
strcat(commandline," was not found!");
sendstr(commandline);
exit(1);}
CRLF(1);
while((fgets(buffer,bufflen,fp))!=NULL){
if(!strcmp(filter,"")){
sendstr(buffer);
xmit('\r');}
else
if(strstr(buffer,filter)){
sendstr(buffer);
xmit('\r');}
}
fclose(fp); }
/*:::::::::::::::::::::::[ Send CR LF ]:::::::::::::::::::::::::::*/
CRLF(int cnt){
int i;
for (i=0;i<cnt;i++){
xmit('\n');
xmit('\r');
printf("\n"); }}
/*::::::::::::::[ SEND ONE CHARACTER TO SERIAL PORT ]::::::::::::::*/
xmit(char ch){
int flag;
regs.h.ah = writech;
regs.x.dx = COMPORT;
regs.h.al = ch;
int86(rs232,®s,®s);
flag =(regs.h.ah&FAILED);
if (flag!=0){
printf(" COM%d failed! ",COMPORT+1);
exit(1);}
}
/*::::::::::::::::::[ Send string to Com ]:::::::::::::::::::::::*/
xmit_str(char *s){
while(*s != '\0'){
xmit(*s);
s++; }}
/*:::::::::::::::::::[ Send string to COM or CON ]::::::::::::::::::*/
sendstr(char *s){
char *str;
str=pcb_printf(s);
xmit_str(str);
}
/*:::::::::::::::::::[ Get command line ]:::::::::::::::::::::::::::*/
getcline(int cnt,char *argarray[]){
int i;
strcat(commandline,'\0');
for(i=2;i<cnt;i++){
if(!strcmp(argarray[i],"/F")){
fileflag=1;
strcpy(commandline,argarray[i+1]);
if(cnt>4) strcpy(filter,argarray[i+2]);
else strcpy(filter,"");
return; }
if(!strcmp(argarray[i],"CR"))
strcat(commandline,CR);
else {
strcat(commandline,argarray[i]);
strcat(commandline," "); }}}
main(int argc,char *argv[]){
char ANSIMODE[5];
mode=0;
strcpy(ANSIMODE,getenv("AN"));
if((strcmp(ANSIMODE,"ON"))==0)
ANSI=1;
COMPORT =atoi(argv[1])-1;
memset(commandline,'\0',255);
getcline(argc,argv);
if (fileflag==1)
display_file(commandline);
else
sendstr(commandline);
}